package com.demo.seckill.common.api;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author libo
 * @ClassName SwaggerConfig
 * @date 2018/11/15 18:05
 * 使用spring-boot-test 需要注释掉，貌似无法兼容
 */
/*@Configuration
@EnableSwagger2*/
public class SwaggerConfig {
    public Docket userApi(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("秒杀案例").apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.demo.seckill.web")).paths(PathSelectors.any()).build();
    }

    public ApiInfo apiInfo(){
        return new ApiInfoBuilder().title("Spring 中使用Swagger2构建文档").termsOfServiceUrl("https://blog.csdn.net/tyllb1234")
                .contact(new Contact("CSDN ", "https://blog.csdn.net/tyllb1234", "1422804242@qq.com")).version("1.1").build();
    }
}
